小编pac*_*an.的帖子

在x86程序集中将整数打印到控制台

当我在16位汇编中添加两个值时,将结果打印到控制台的最佳方法是什么?

目前我有这个代码:

;;---CODE START---;;
mov ax, 1   ;put 1 into ax
add ax, 2   ; add 2 to ax current value
mov ah,2  ; 2 is the function number of output char in the DOS Services.
mov dl, ax ; DL takes the value.
int 21h    ; calls DOS Services

mov ah,4Ch   ; 4Ch is the function number for exit program in DOS Services.
int 21h      ; function 4Ch doesn't care about anything in the registers.
;;---CODE END---;;
Run Code Online (Sandbox Code Playgroud)

我认为dl值应该是ASCII码,但我不确定如何在添加到ASCII后转换ax值.

assembly dos 16-bit

7
推荐指数
2
解决办法
2万
查看次数

将列表拆分为已排序的子列表

如何将列表[1,2,4,1,5,7,3,4,2,3]划分为一个子列表列表,这些子列表将按断开序列的值进行拆分.例如,列表[1,2,4,1,5,7,3,4,2,3]应该产生一个子列表,如[[1,2,4],[1,5,7],[ 3,4],[2,3].

有关此的任何想法或建议如何解决此问题?

谢谢.

haskell functional-programming

6
推荐指数
2
解决办法
1357
查看次数

在prolog中定义多个规则的最短方法

我正在尝试解决一个练习,以便更熟悉prolog.

任务如下:

% Sten wants to send Lisa 100 flowers. He can choose from lilies, roses and tulips.
% One lily costs $50, rose $10 and tulip $1. Find how many flowers of each type he 
% must buy, so that he spends exactly $500.
Run Code Online (Sandbox Code Playgroud)

我已经解决了这个练习,但我觉得有点笨重.我的代码是:

% numbers 1..100
digit(1). digit(2). digit(3). digit(4). digit(5). digit(6). digit(7). digit(8).
digit(9). digit(10). digit(11). digit(12). digit(13). digit(14). digit(15). digit(16). 
digit(17). digit(18). digit(19). digit(20). digit(21). digit(22). digit(23). digit(24). 
digit(25). digit(26). digit(27). digit(28). digit(29). digit(30). digit(31). …
Run Code Online (Sandbox Code Playgroud)

prolog logic-programming clpfd

4
推荐指数
2
解决办法
1441
查看次数