對於科學展覽會,我需要三個程序數到50,000,並輸出每個數字,我需要一個在C++中,一個在Java中,一個在裝配中。我有C++和Java程序,但我不明白我在做什麼錯了我的彙編代碼:計數器裝配
[org 0x100]
[bits 32]
mov ax, 0
mov bx, target
jmp start
start:
mov cx, 0x01
add ax, cx
mov dx, ax
mov ah, 09
int 0x21
mov ax, dx
cmp ax, bx
jg term
jmp start
term:
mov dx, msgT
mov ah, 09
int 0x21
mov ah, 00
int 0x21
msgT db 'Terminating'
target dw 50000
我使用匯編NASM,而現在,它計數至50000,但沒有按」在計算它們時輸出每個數字。
您在哪個平臺上運行該平臺? –
對不起,我忘了包括。我在Windows 7上運行它 – JAW1025
如果你想製作一個16位的MS-DOS com文件,你應該使用'[bits 16]'。並且@Vlad說AH = 09h在DX中使用一個字符串而不是一個數字(參見例如[here](http://stackoverflow.com/questions/7863094/how-can-i-convert-hex-to-decimal/7865387) #7865387)關於如何將一個數字轉換爲字符串,還要注意,您將不得不'' - 終止字符串而不是NUL - 終止它)。 – user786653